
import ServiceBase from "../components/ServiceBase";
import DefaultService from "../components/DefaultService";

class ServiceUtils {
	public getService(): ServiceBase {
		if(getApp && getApp() && getApp().ServiceUtils) {
			let utils = getApp().ServiceUtils;
			return utils.getInstance();
		}

		if(getApp && getApp() && getApp().$service) {
			return <ServiceBase>getApp().$service;
		}

		if(uni && (<any>uni).$service) {
			return <ServiceBase>(<any>uni).$service;
		}

		return DefaultService;
	}
}

export default new ServiceUtils();
